package com.xiaoniu.workflow.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestOperations;
import org.springframework.web.client.RestTemplate;

/**
 * RestTemplate配置类
 * 
 * @author
 *
 */
@Configuration
public class RestConfiguration {

	@Bean
	@ConditionalOnMissingBean({ RestOperations.class, RestTemplate.class })
	public RestOperations restOperations() {
		SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
		// 设置连接超时，单位：毫秒
		requestFactory.setConnectTimeout(8000);
		// 设置读取超时，单位：毫秒
		requestFactory.setReadTimeout(8000);

		RestTemplate restTemplate = new RestTemplate(requestFactory);

		return restTemplate;
	}
	

}